proc format;
	value metro2x 0="Principal MSA" 1="Other MSA" 2="Not MSA";
	value insur2x
	value; 



data mydata.LCA1119aim3;
set mydata.LCA1119aim3;
/************************* Descriptive statistics: SDOH varables by PHP outcomes***************************/
ods rtf file="C:\Users\anakwea\Desktop\Men\RTF_results\2011_2019\Aim2\descriptives by php";
proc surveyfreq data=mydata.LCA1119aim3;
	tables php / col row nowt chisq;
	weight weightvar;
    cluster panelvar;
	strata stratvar;
run;
 
proc surveyfreq data=mydata.LCA1119aim3;
	tables (metro2 insur2 reprohlth workcons2 pir0 educ hisprace0 immi UNION2 kiddos ages sexage2 year)* php/ col row nowt chisq;
	weight weightvar;
    cluster panelvar;
	strata stratvar;
run;
ods rtf close;

	/************************Multinomial regression models with PHP as DV/Outcome variable*********************/
proc freq data=mydata.LCA1119aim3; tables hisprace2 hisprace0 kids age sexage; run;
/*****************************MULTINOMIAL REGRESSION MODELS FOR RACE (CRUDE< ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for RACE***********************************************************/
ods rtf file="C:\Users\anakwea\Desktop\Men\RTF_results\2011_2019\Aim2\Multinomial_regressions";
proc surveylogistic data=mydata.LCA1119aim3;
class hisprace0(ref="0")/ param=ref; /*NHW as baseline category*/
model php (ref="lowest risk") = hisprace0 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class hisprace0(ref="0")/ param=ref;/*NHW as baseline category*/
model php (ref="substance users") = hisprace0 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*************************Adjusted model for RACE*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class  hisprace0(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year (ref="2012")/ param=ref; /*NHW as baseline category*/
model php(ref="lowest risk") =  hisprace0 UNION3 kids age sexage year / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class  hisprace0(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year (ref="2012")/ param=ref;/*NHW as baseline category*/
model php(ref="substance users") =  hisprace0 UNION3 kids age sexage year / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc freq data=mydata.LCA1119aim3; tables php metro2; run;
/*****************************MULTINOMIAL REGRESSION MODELS FOR METRO(CRUDE< ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for METRO***********************************************************/

proc surveylogistic data=mydata.LCA1119aim3;
class metro2(ref="2")/ param=ref;/*Principal MSA as baseline*//*Not MSA as baseline*/
model php (ref="lowest risk") = metro2 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class metro2(ref="2")/ param=ref;/*Principal MSA as baseline*/
model php (ref="substance users") = metro2 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*************************Adjusted model for METRO*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class metro2(ref="2") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year (ref="2012")/ param=ref;/*Principal MSA as baseline*/
model php (ref="lowest risk") = metro2 UNION3 kids age sexage year / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class metro2(ref="2") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ param=ref;/*Principal MSA as baseline*/
model php (ref="substance users") = metro2 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*****************************MULTINOMIAL REGRESSION MODELS FOR INSURANCE(CRUDE< ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for INSURANCE***********************************************************/
proc freq data=mydata.LCA1119aim3; tables insur2; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class insur2(ref="1")/ param=ref; /*ref= insured*/
model php (ref="lowest risk") = insur2 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class insur2(ref="1")/ param=ref; /*ref= insured*/
model php (ref="substance users") = insur2 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*************************Adjusted model for INSUR*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class insur2(ref="0") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year(ref="2012")/ param=ref;/*ref= insured*/
model php (ref="lowest risk") = insur2 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class insur2(ref="0") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year(ref="2012")/ param=ref;/*ref= insured*/
model php (ref="substance users") = insur2 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*****************************MULTINOMIAL REGRESSION MODELS FOR REPROHEALTH(CRUDE< ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for REPROHLTH***********************************************************/
proc freq data=mydata.LCA1119aim3; tables REPROHLTH year; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class reprohlth(ref="2")/ param=ref; /*ref= yes reproductive health visit*/
model php (ref="lowest risk") = reprohlth / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class reprohlth(ref="2")/ param=ref; /*ref= yes reproductive health visit*/
model php (ref="substance users") = reprohlth / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/*************************Adjusted model for REPROHLTH*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class reprohlth(ref="2")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= yes reproductive health visit*/
model php (ref="lowest risk") = reprohlth UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class reprohlth(ref="2")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year(ref="2012")/ 
param=ref;  /*ref= yes rproductive health visit*/
model php (ref="substance users") = reprohlth UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/***************MULTINOMIAL REGRESSION MODELS FOR EMPLOYMENT CONSISTENCY CRUDE,ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for REPROHLTH***********************************************************/
proc freq data=mydata.LCA1119aim3; tables workcons2 workcons; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class workcons2(ref="2")/ param=ref; /*ref= yes stable employment*/
model php (ref="lowest risk") = workcons2/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class workcons2(ref="2")/ param=ref; /*ref= yes stable employment*/
model php (ref="substance users") = workcons2/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/*************************Adjusted model for REPROHLTH*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class workcons2(ref="2")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= yes stable employment*/
model php (ref="lowest risk") = workcons2 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class workcons2(ref="2")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= yes stable employment*/
model php (ref="substance users") = workcons2 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/***************MULTINOMIAL REGRESSION MODELS FOR POVERTY/INCOME RATIO-CRUDE,ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for PIR***********************************************************/
proc freq data=mydata.LCA1119aim3; tables pir0; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class pir0(ref="1")/ param=ref; /*ref= above 100% poverty*/
model php (ref="lowest risk") = pir0/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class pir0(ref="1")/ param=ref; /*ref= above 100% poverty*/
model php (ref="substance users") = pir0/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/*************************Adjusted model for PIR*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class pir0(ref="1")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= above 100% poverty*/
model php (ref="lowest risk") = pir0 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class pir0(ref="1")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= above 100% poverty*/
model php (ref="substance users") = pir0 UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/***************MULTINOMIAL REGRESSION MODELS FOR EDUCATION STATUS RATIO-CRUDE,ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for EDUC***********************************************************/
proc freq data=mydata.LCA1119aim3; tables educ; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class educ(ref="0")/ param=ref; /*ref= less than HS educ*/
model php (ref="lowest risk") = educ/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class educ(ref="0")/ param=ref; /*ref= less than HS educ*/
model php (ref="substance users") = educ/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/*************************Adjusted model for EDUC*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class educ(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= less than HS educ*/
model php (ref="lowest risk") = educ UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class educ(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= less than HS educ*/
model php (ref="substance users") = educ UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
/***************MULTINOMIAL REGRESSION MODELS FOR IMMIGRATION STATUS RATIO-CRUDE,ADJUSTED and when the REF category changes********/
/************************CRUDE analysis for IMMIGRATION***********************************************************/
proc freq data=mydata.LCA1119aim3; tables immi; run; 

proc surveylogistic data=mydata.LCA1119aim3;
class immi(ref="0")/ param=ref; /*ref= non-immigrant*/
model php (ref="lowest risk") = immi/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class immi(ref="0")/ param=ref;/*ref= non-immigrant*/
model php (ref="substance users") = immi/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

/*************************Adjusted model for IMMIGRATION*********************************************************/
proc surveylogistic data=mydata.LCA1119aim3;
class immi(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= non-immigrant*/
model php (ref="lowest risk") = immi UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class immi(ref="0")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= non immigrant*/
model php (ref="substance users") = immi UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
ods rtf close;
/****************************END OF AIM 2 ANALYSIS*************************************************/
/**************************************************************************************************/
/**************************************************************************************************/


/*************************Adjusted model for METRO using urban/rural categories*********************************************************/
data mydata.LCA1119aim3;
set mydata.LCA1119aim3;
	if metro2 in (0:1) then metro3=0; else if metro2=2 then metro3=1; run;
proc freq data=mydata.LCA1119aim3; tables metro2; run;

proc surveylogistic data=mydata.LCA1119aim3;
class metro3(ref="1")/ param=ref;/*Principal MSA as baseline*//*Not MSA as baseline*/
model php (ref="lowest risk") = metro3 / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
proc surveylogistic data=mydata.LCA1119aim3;
class metro3(ref="1") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year (ref="2012")/ param=ref;/*Principal MSA as baseline*/
model php (ref="lowest risk") = metro3 UNION3 kids age sexage year / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc surveylogistic data=mydata.LCA1119aim3;
class metro2(ref="2") union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2") year (ref="2012")/ param=ref;/*Principal MSA as baseline*/
model php (ref="lowest risk") = metro2 UNION3 kids age sexage year / link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;

proc freq data=mydata.LCA1119aim3; tables hisprace0 metro2 insur2 reprohlth workcons2 pir0 educ immi; run;

proc surveylogistic data=mydata.LCA1119aim3;
class educ(ref="3")union3(ref="0") kids(ref="3") age(ref="4") sexage(ref="2")year (ref="2012")/ 
param=ref; /*ref= less than HS educ*/
model php (ref="lowest risk") = educ UNION3 kids age sexage year/ link=glogit; 
weight weightvar;
cluster panelvar;
strata stratvar;
run;
